package com.yowasa.xiuxian.engine.battle.enemy.strategy;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import com.yowasa.xiuxian.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name = "奥赛尔")
@Order(1006)
@Component
public class AoSaiEr extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int dmg;
        String desc;
        int i = RandomUtil.randomInt(1);
        if (i == 0) {
            int orgAtk = first.getBattleInfo().getAtk();
            int def = second.getBattleInfo().getDef();
            int atk = (int) (orgAtk * 1.2);
            dmg = battleHelper.calAtk(atk, def);
            desc = RandomUtil.choice(Lists.newArrayList("水流冲击","水箭落"));
        } else{

            int orgAtk = first.getBattleInfo().getSpell();
            int def = second.getBattleInfo().getRes();
            desc = RandomUtil.choice(Lists.newArrayList("断雨","水形剑","激流","一箭止水"));
            double random = Math.random();
            if(random < 0.2){
                random+= 1.8;
                desc = RandomUtil.choice(Lists.newArrayList("星海游鲸","势如狂澜"));
            }else {
                random+= 0.7;
            }
            int atk = (int) (orgAtk * random);
            dmg = battleHelper.calSpell(atk, def);

        }
        battleHelper.autoAction(this, first, second, content, dmg, desc);
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("无法学习妖兽的攻击手段");
    }

    @Override
    public String limitDesc() {
        return "无";
    }

    @Override
    public String desc() {
        return  " [你的命运将成为纷争的风暴之眼]\n" +
                "「铁剑交错的声响是常伴你的奏乐]\n" +
                "「踏入至暗之处的漆黑记忆]\n" +
                "「终将成为你颠覆世界的力量吧]\n\n"+
                "会使用强大的法术攻击 \n" +
                "物理 ：水流冲击,水箭落\n" +
                "法术 ：断雨,水形剑,激流，一箭止水，星海游鲸，势如狂澜\n\n" +
                "掉落物：\n" +
                "武炼之魂孤影,魔王之刃残片,吞天之鲸号角，星海游鲸秘籍";
    }


}
